<?php
/**
 * Created by PhpStorm.
 * User: apple
 * Date: 2020/10/13
 * Time: 5:28 PM
 */
namespace app\model;


use think\facade\Db;
use think\Model;

class UserVideo extends Model{
    protected $table = 'user_video';
    protected $pk = 'uv_id';

    protected static function init(){
        //TODO:初始化内容
    }


    public function getUserLastPlayInfoByUidAndVideoId($uid,$videoId)
    {
        $where = [
            'uv_uid' => $uid,
            'uv_vid' => $videoId,
        ];

        return Db::table('user_video')->where($where)->order('uv_id desc')->limit(1)->find();
    }

    public function addOnePlay($data){
        $data['uv_create_time'] = time();
        return Db::table('user_video')->insertGetId($data);
    }
}